package com.elbis.access.wg.api.request.account;

import java.util.Iterator;
import java.util.List;

import com.elbis.access.wg.api.request.WOTRequestEntity;

public class VehicleData extends WOTRequestEntity {

	private static final long serialVersionUID = 3378287104476278079L;

	private String language = null;

	private String fields = null;

	private String access_token = null;

	private List<Long> account_id = null;

	private List<Long> tank_id = null;

	public VehicleData(String applicationId, List<Long> accountIds) {
		super(applicationId);
		account_id = accountIds;
	}

	/**
	 * @return the language
	 */
	public String getLanguage() {
		return language;
	}

	/**
	 * @param language
	 *            the language to set
	 */
	public void setLanguage(String language) {
		this.language = language;
	}

	/**
	 * @return the fields
	 */
	public String getFields() {
		return fields;
	}

	/**
	 * @param fields
	 *            the fields to set
	 */
	public void setFields(String fields) {
		this.fields = fields;
	}

	/**
	 * @return the access_token
	 */
	public String getAccess_token() {
		return access_token;
	}

	/**
	 * @param access_token
	 *            the access_token to set
	 */
	public void setAccess_token(String access_token) {
		this.access_token = access_token;
	}

	/**
	 * @return the account_id
	 */
	public List<Long> getAccount_id() {
		return account_id;
	}

	/**
	 * @param account_id
	 *            the account_id to set
	 */
	public void setAccount_id(List<Long> account_id) {
		this.account_id = account_id;
	}

	/**
	 * @return the tank_id
	 */
	public List<Long> getTank_id() {
		return tank_id;
	}

	/**
	 * @param tank_id
	 *            the tank_id to set
	 */
	public void setTank_id(List<Long> tank_id) {
		this.tank_id = tank_id;
	}

	@Override
	public String toHttpRequestParameters() {
		StringBuilder builder = new StringBuilder(
				super.toHttpRequestParameters());
		if (language != null) {
			builder.append("&");
			builder.append("language=");
			builder.append(language);
		}
		if (fields != null) {
			builder.append("&");
			builder.append("fields=");
			builder.append(fields);
		}
		if (access_token != null) {
			builder.append("&");
			builder.append("access_token=");
			builder.append(access_token);
		}
		if (account_id != null) {
			builder.append("&");
			builder.append("account_id=");
			Iterator<Long> accountIterator = account_id.iterator();
			while (accountIterator.hasNext()) {
				Long id = accountIterator.next();
				builder.append(id);
				if (accountIterator.hasNext()) {
					builder.append(',');
				}
			}
		}

		if (tank_id != null) {
			builder.append("&");
			builder.append("tank_id=");
			Iterator<Long> tankIterator = tank_id.iterator();
			while (tankIterator.hasNext()) {
				Long id = tankIterator.next();
				builder.append(id);
				if (tankIterator.hasNext()) {
					builder.append(',');
				}
			}
		}

		return builder.toString();
	}

}
